package com.quanyan.stadium.service.impl;

import com.quanyan.stadium.biz.BizDatesportDao;
import com.quanyan.stadium.entity.TbDatesportInfo;
import com.quanyan.statium.api.resp.RespDatesportInfoDetail;
import com.quanyan.statium.service.DatesportDubboService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * Created by lei.w on 2017/3/7.
 */
@Service("datesportDubboService")
public class DatesportDubboServiceImpl implements DatesportDubboService {

    private final static Logger logger = LoggerFactory.getLogger(DatesportDubboServiceImpl.class);

    @Autowired
    BizDatesportDao bizDatesportDao;

    @Override
    public List<RespDatesportInfoDetail> queryBatchDatesportDetails(List<Integer> idList) {
        List<RespDatesportInfoDetail> respDatesportInfoDetailList = Collections.emptyList();
        if (null == idList || idList.size() == 0 || idList.size() > 10) {
            logger.info("queryBatchDatesportDetails the parameter idList is not legal");
            return respDatesportInfoDetailList;
        }

        List<TbDatesportInfo> tbDatesportInfoList = bizDatesportDao.selectDatesportInfoList(idList);
        if (null != tbDatesportInfoList && tbDatesportInfoList.size() >0 ) {
            respDatesportInfoDetailList = new ArrayList<>();
            RespDatesportInfoDetail respDatesportInfoDetail;
            for (TbDatesportInfo tbDatesportInfo : tbDatesportInfoList) {
                respDatesportInfoDetail = new RespDatesportInfoDetail();
                BeanUtils.copyProperties(tbDatesportInfo, respDatesportInfoDetail);

                respDatesportInfoDetailList.add(respDatesportInfoDetail);
            }
        }

        return respDatesportInfoDetailList;
    }
}
